package com.far;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.MotionEvent;

public class SplashActivity extends Activity {
	
	protected int mSplashTime = 4000;
	private Thread mSplashThread;
	final SplashActivity mSplashScreen = this;
	
	
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.splash);
        mSplashThread = new Thread(){
        	@SuppressWarnings("finally")
			public void run(){
        		try{
        			synchronized(this){
        				wait(mSplashTime);
        			}
        		} catch (InterruptedException e){}
        		finally{
        			Intent i = new Intent();
        			i.setClass(mSplashScreen, MainMenu.class);
        			mSplashScreen.startActivity(i);
        			mSplashScreen.finish();
        			overridePendingTransition(R.anim.fadein, R.anim.fadeout);
        			return;
        		}
        	}
        };
        
        mSplashThread.start();
    }
    
    @Override
    protected void onPause(){
    	super.onPause();
    }
    
    @Override
    protected void onResume(){
    	super.onResume();
    }
    
    @Override
    public boolean onTouchEvent(MotionEvent event){
    	if(event.getAction() == MotionEvent.ACTION_DOWN){
    		synchronized(mSplashThread){
    			overridePendingTransition(R.anim.fadein, R.anim.fadeout);
    			mSplashThread.notifyAll();
    		}
    	}
    	return true;
    }
}